package com.itheima.exam.web;


import com.itheima.exam.pojo.entity.Student;
import com.itheima.exam.pojo.vo.StudentVo;
import com.itheima.exam.service.StudentService;
import com.itheima.exam.web.result.PageResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("students")
public class StudentController {
    @Autowired
    StudentService studentService;

    @PostMapping("page")
    public PageResult<Student> page(int currentPage, int pageSize, @RequestBody Student student){
        //当前页码对应的数据
        List<StudentVo> page = studentService.page(currentPage, pageSize, student);
        //查询数据的总条数
        int row = studentService.rows(student);
        return PageResult.OK(page,row);
    }
}
